package com.example.liuanlu.myapplication;

import android.telephony.TelephonyManager;

import java.io.Serializable;

/**
 * Created by liuanlu on 2017/1/5.
 */

public class SingletonF implements Serializable {

    public TelephonyManager tm;

    private static class SingletonHolder {

        static final SingletonF INSTANCE = new SingletonF();
    }

    public static SingletonF getInstance() {
        return SingletonHolder.INSTANCE;
    }

    /**
     * private的构造函数用于避免外界直接使用new来实例化对象
     */
    private SingletonF() {}

    /**
     * readResolve方法应对单例对象被序列化时候
     */
    private Object readResolve() {
        return getInstance();
    }
}
